package model.entity;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import model.map.MapPoint;
import model.mediators.InteractiveMediator;
import model.stats.*;

/**
 * 
 *
 */
public class NPC extends Entity implements Cloneable{

	private static int favorabilityThreshold = 25;
	private AIBehavior behavior;
	private Stat favorability;
	private ArrayList<Entity> hostilityList;
	
	/**
	 * 
	 */
	public NPC() {
		super();
		this.behavior= new Wander();
		this.favorability = new Stat("favorability", 42);
	}
	
	public NPC(String name, String occName, MapPoint origin, StatsContainer stats,
			MovementType movement, int obs, int bar, int bind, DirectionalGraphicSet graphics, AIBehavior ai, Stat favor){
		super( name,  occName,  origin,  stats,
				 movement,  obs,  bar,  bind,  graphics);
	}
	//will need to be changed to give behavior a reference to this npc as soon as behavior is fleshed out
	public NPC(AIBehavior ai, Stat favor){
		super();
		this.behavior=ai;
		this.favorability=favor;
	}
	
	
	public void setAttack(Entity target){
		behavior=new Attack(target);
	}
	
	public void setWander(){
		behavior=new Wander();
	}
	
	public void setStand(){
		behavior = new StandStill();
	}

	public void setFollow(Entity leader){
		behavior = new Follow(10,leader);
	}
	
	public boolean isFavorable() {
		return favorability.getValue() >= favorabilityThreshold;
	}
	
	public void affectFavorability(int mag, int dur){
		favorability.addTempMod(mag, dur);
	}
	
	//updates time dependent variables
	public void update(){
		super.update();
		favorability.update();
		behavior.update(this);
	}
	
	public void talk(){
		
	}

	public void interactWith(List<Entity> entityList) {
	}



	public void notifyOfDeath(Entity entity) {
		hostilityList.remove(entity);
	}


	public void makeHostile(Entity caster) {
		hostilityList.add(caster);
	}


	@Override
	public void enchant(int baseValue) {
	}


	public void levelup() {
		
	}

	public NPC clone() throws CloneNotSupportedException {
		return (NPC)super.clone();
	}
	
	
}
